var a = getApp();

Page({
    data: {
        balance: 0,
        listData: [],
        love_name: "",
        usable: 0,
        loading: !1,
        allLoaded: !1,
        goload: !0,
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(a) {
        this.initData(), this.getUsable(), this.getNetData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.data.isLoadMore ? this.getMoreData(this.data.page) : wx.showToast({
            title: "没有更多数据",
            icon: "none"
        });
    },
    onReachBottom: function() {
        this.data.isLoadMore && this.getMoreData(this.data.page);
    },
    onShareAppMessage: function() {},
    getUsable: function() {
        var t = this, e = a.getNetAddresss("plugin.love.Frontend.Controllers.page.index");
        a._getNetWork({
            url: e,
            success: function(a) {
                1 === a.data.result ? t.setData({
                    usable: a.data.data.usable,
                    love_name: a.data.data.love_name
                }) : wx.showToast({
                    title: a.data.msg,
                    icon: "none"
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    initData: function() {
        this.page = 1, this.total_page = 0, this.goload = !0, this.loading = !0, this.allLoaded = !1, 
        this.isLoadMore = !0, this.listData = [];
    },
    goDetailed: function(a) {
        console.log(a, "详情"), wx.navigateTo({
            url: "/packageB/member/love/love_activation/love_activation?id=" + a.currentTarget.dataset.id
        });
    },
    getNetData: function() {
        var t = this, e = a.getNetAddresss("plugin.love.Frontend.Modules.Love.Controllers.activation-records.index");
        e += "&page=" + this.data.page, a._getNetWork({
            url: e,
            success: function(a) {
                1 == a.data.result ? t.setData({
                    listData: a.data.data.data,
                    total_page: a.data.data.last_page
                }) : wx.showToast({
                    title: a.data.msg,
                    icon: "none"
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    getMoreData: function(t) {
        var e = this;
        if (this.data.page != this.data.total_page) if (this.data.page >= this.data.total_page) this.setData({
            loading: !0,
            allLoaded: !0
        }); else {
            this.setData({
                page: this.data.page + 1
            });
            var o = a.getNetAddresss("plugin.love.Frontend.Modules.Love.Controllers.activation-records.index");
            o += "&page=" + this.data.page, a._getNetWork({
                url: o,
                success: function(a) {
                    if (1 == a.data.result) {
                        var t = a.data.data, o = e.data.listData.concat(t.data);
                        e.setData({
                            loading: !1,
                            allLoaded: !1,
                            listData: o
                        });
                    } else {
                        var s = e.data.page - 1;
                        e.setData({
                            page: s,
                            loading: !0,
                            allLoaded: !0,
                            isLoadMore: !1
                        });
                    }
                },
                fail: function(a) {
                    console.log(a);
                }
            });
        } else a.tips("没有更多数据了");
    }
});